<?php
/**
 * @link https://www.kancloud.cn/cleverstone/ymb2
 * @copyright Copyright (c) 2020 Yii Manager Software LLC
 */

/** @var \yii\web\View $this */
/** @var \builder\card\CardBuilder $context 当前组件实例 */
/** @var array $rootLayout 根布局 */
/** @var array $cardItem 卡片项 */

$context = $this->context;
$componentID = $context->id;
$angularControllerID = "ym2.ctrl.$componentID";

?>
    <div ng-controller="<?= $angularControllerID ?>" class="layui-row <?= $rootLayout['class'] ?>" style="<?= $rootLayout['style'] ?>"<?= $rootLayout['attribute'] ?>>
        <!--页面开始-->
        <?= $context->beginPage() ?>

        <!--卡片或面板部分-->
<?php foreach ($cardItem as $item): ?>
<?php switch ($item['type']): ?>
<?php case 'card': //卡片面板 ?>
        <div class="layui-card layui-col-sm12 layui-col-md<?= $item['layout'] ?> <?= $item['class'] ?>" style="<?= $item['style'] ?>"<?= $item['attribute'] ?>>
<?php if (!empty($item['header']) || !empty($item['help']) || !empty($item['comment'])): ?>
            <div class="layui-card-header builder-card-header">
                <?= $item['header'] ?>
<?php if (!empty($item['help'])): ?>
                <!--帮助-->
                <i style="cursor: help;"
                   class="layui-icon layui-icon-tips layui-font-gray f14"
                   data-toggle="popover"
                   data-trigger="hover"
                   data-custom-class="f13 white-space-pre-wrap pointer-event-none"
                   data-html="true"
                   data-content="<?= \builder\helper\H5::encode($item['help']) ?>"
                   ym2-bootstrap-plugin="popover"></i>
<?php endif; ?>
<?php if (!empty($item['comment'])): ?>
                <comment class="text-comment pl-1 f12"><?= $item['comment'] ?></comment>
<?php endif; ?>
            </div>
<?php endif; ?>
<?php if (!empty($item['body'])): ?>
            <div class="layui-card-body p-0">
                <?= $item['body'] ?>
            </div>
<?php endif; ?>
<?php if (!empty($item['footer'])): ?>
            <div class="card-footer bg-white border-0">
                <?= $item['footer'] ?>
            </div>
<?php endif; ?>
        </div>
<?php break; case 'panel': //普通面板 ?>
        <div class="layui-panel p-3 layui-col-sm12 layui-col-md<?= $item['layout'] ?> <?= $item['class'] ?>" style="<?= $item['style'] ?>"<?= $item['attribute'] ?>>
<?php if (!empty($item['help']) || !empty($item['comment'])): ?>
            <div class="d-flex align-items-center">
<?php if (!empty($item['help'])): ?>
                <!--帮助-->
                <i style="cursor: help;"
                   class="layui-icon layui-icon-tips layui-font-gray f14 mr-2"
                   data-toggle="popover"
                   data-trigger="hover"
                   data-custom-class="f13 white-space-pre-wrap pointer-event-none"
                   data-html="true"
                   data-content="<?= \builder\helper\H5::encode($item['help']) ?>"
                   ym2-bootstrap-plugin="popover"></i>
<?php endif; ?>
                <comment class="text-comment f12 pb-1"><?= $item['comment'] ?></comment>
            </div>
<?php endif; ?>
            <div class="mt-1">
                <?= $item['body'] ?>
            </div>
        </div>
<?php break; endswitch; ?>
<?php endforeach; ?>

        <!--页面结束-->
        <?= $context->endPage() ?>
    </div>
